package com.cookman.gameobjects;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.cookman.assets.AssetMap;
import com.cookman.assets.AssetsImpl;
import com.cookman.assets.AssetsLocator;
import com.cookman.factories.CitiesFactory;
import com.cookman.utils.Constants;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Cookman on 03.05.14.
 */
public class WorldMap extends Group {

    Sprite backgroundSprite = AssetsLocator.getSpriteByAtlasRegion(AssetsImpl.MAP, AssetMap.MAP);

    private List<CityActor> cities = new ArrayList<CityActor>();

    public WorldMap() {
    }

    public void init() {
        this.cities = CitiesFactory.getCities();
        for (CityActor city : cities) {
            addActor(city);
        }
    }

    public void render(SpriteBatch batch) {
        backgroundSprite.setSize(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT);
        backgroundSprite.draw(batch);
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        super.draw(batch, parentAlpha);
    }

    public void renderGUI(SpriteBatch batch) {
        for (CityActor city : cities) {
            city.renderGUI(batch);
        }
    }

    public void renderShape(ShapeRenderer renderer) {
        for (CityActor city : cities) {
            city.renderShape(renderer);
        }
    }
}
